# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=send2trash
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}" "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=1.5.0
pkgrel=1
pkgdesc="Send file to trash natively (mingw-w64)"
url="https://github.com/hsoft/send2trash"
arch=('any')
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/hsoft/${_realname}/archive/$pkgver.tar.gz)
sha256sums=('7cebc0ffc8b6d6e553bce9c6bb915614610ba2dec17c2f0643b1b97251da2a41')


prepare() {
  cd "$srcdir"/

  for pver in {2,3}; do
    rm -rf python${pver}-build-${CARCH} | true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done

}

build() {
  for pver in {2,3}; do
    msg "Python ${pver} build for ${CARCH}"
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done
}

package_python3-send2trash() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/"python${pver}-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1

  install -D -m644 "LICENSE" ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}

package_python2-send2trash() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/"python${pver}-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1

  install -D -m644 "LICENSE" ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}

package_mingw-w64-i686-python2-send2trash() {
  package_python2-send2trash
}

package_mingw-w64-i686-python3-send2trash() {
  package_python3-send2trash
}

package_mingw-w64-x86_64-python2-send2trash() {
  package_python2-send2trash
}

package_mingw-w64-x86_64-python3-send2trash() {
  package_python3-send2trash
}
